<!DOCTYPE html>
<html>
<head>
<title>添加供电所信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!--删除默认的苹果工具栏和菜单栏。-->
		<link rel="stylesheet" href="plug-in/ydui/css/ydui.css?rev=@@hash"/>
		<link rel="stylesheet" href="plug-in/ydui/css/demo.css"/>
		<link rel="stylesheet" href="plug-in/Validform/css/style.css"/>
		<script src="plug-in/ydui/js/ydui.flexible.js"></script>
		<style type="text/css">
			.demo-pagetitle{
				position:relative;
				top:10%;
			}
	    	.m-grids-4{
	    		top:20%;
	    		background:transparent;
	    	}
	    	
			.m-grids-4 .grids-item {
				width: 50%;
			}
			.demo-icons [class^="icon-"]:before, .demo-icons [class*=" icon-"]:before { font-size: 0.6rem; color: #FF685D; }
    	</style>
		<link rel="stylesheet" href="webpage/css/login-main.css" />
		<link rel="stylesheet" href="webpage/css/faultfeedback.min.css" />
		<script type="text/javascript">
		</script>
</head>
<body>
	<!-- <div class="div"></div> -->
	<section class="g-flexview">
		<form id="form" name="form" class="registerform" method="post">
		<header class="m-navbar">
        	<a class="navbar-item" onclick="window.history.go(-1)"><i class="back-ico"></i></a>
        	<div class="navbar-center"><span class="navbar-title">添加供电所信息</span></div>
        	<input id="js_submit" class="navbar-right" type="submit" value="提交" />
    	</header>
	    <section class="g-scrollview">
	        <div class="m-cell demo-small-pitch">
	        	<div class="cell-item" style="display:none">
	                <div class="cell-left">id:</div>
	                <div class="cell-right">
	                	<input id="id" name="id" type="text" class="cell-input" placeholder="请输入单位编码" autocomplete="off" />
	                </div>
	            </div>
	            <div class="cell-item">
	                <div class="cell-left">单位编码：</div>
	                <div class="cell-right" id="divcomCode">
	                	<input id="comCode" name="comCode" type="text" class="cell-input" placeholder="请输入单位编码" autocomplete="off" datatype="infodepart,*" sucmsg="验证信息通过！"/>
	                	<span class="Validform_checktip"></span>
	                </div>
	            </div>
	            <div class="cell-item">
	                <div class="cell-left">所在县/区：</div>
	                <div class="cell-right"><input id="comRegionName" name="comRegionName" type="text" class="cell-input" placeholder="请输入行政区域名称" autocomplete="off" datatype="*"/></div>
	            </div>
	            <div class="cell-item">
	                <div class="cell-left">供电所名称：</div>
	                <div class="cell-right"><input id="comPlaceName" name="comPlaceName" type="text" class="cell-input" placeholder="请输入供电所名称" autocomplete="off" datatype="*"/></div>
	            </div>
	            <div class="m-cell">
					<label class="cell-item">
						<span class="cell-left">是否激活：</span>
						<label class="cell-right">
							<input id="comStatus" name="comStatus" type="checkbox" class="m-switch" value="0"/>
						</label>
					</label>
				</div>
			</div>
		</section>
		</form>
	</section>
</body>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="webpage/js/ydui.city.js"></script>
<script src="plug-in/ydui/js/ydui.js"></script>
<script src="http://malsup.github.io/jquery.form.js"></script>
<script type="text/javascript" src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js"></script>
<script type="text/javascript" src="plug-in/Validform/js/initValidform.js"></script>
<script type="text/javascript">
$(function(){
 	$(".registerform").Validform({
		tiptype:4,
		dragonfly:false,
		ignoreHidden:true,
		postonce:true,
		usePlugin:{
			passwordstrength:{
				minLen:6,
				maxLen:18
			}
		},
		datatype:{//传入自定义datatype类型【方式二】;
			"infodepart":function(gets,obj,curform,regxp){//
				if(gets!=null){
					$.ajax({
						type: 'post', // 提交方式 get/post
				   		url: "volidformController.do?infoCompanies", // 需要提交的 url
				  		data:{'string':gets},
				   		dataType:"json",
				       	success: function(json){ // data 保存提交后返回的数据，一般为 json 数据
				       		if(!json.success){
				       			$("#comCode").removeClass();
				       			$("#comCode").addClass("cell-input");
				       			$("#divcomCode span").text("通过信息验证！");
				       			return false;
				       		}else{
				       			$("#comCode").addClass("Validform_error");
				       			$("#divcomCode span").text("该单位已存在");
				       			$("#divcomCode span").removeClass();
				       			$("#divcomCode span").addClass("Validform_checktip Validform_wrong")
				       			return false;
				       		}
				       		return false;
				       	},
				       	error: function(){}
					})
				}
			},
		}
	})
}) 
	$('#js_submit').on('click', function(){
		var comStatus = $("#comStatus");
		if($("#comStatus").is(":checked")){
			comStatus.attr("value",1);
		}else{
			comStatus.attr("value",0);
			//comStatus = 0;
		}
		if(!StopSubmit()){
			return false;
		}
		var check=confirm("您确定要提交表单吗？");
		if(!check){
			return false;
		}
		$('#form').on('submit', function(){
			$.ajax({
				type: 'post', // 提交方式 get/post
				async:false,
		   		url: "systemController.do?doAddCompanise", // 需要提交的 url
		  		data:$('form').serialize(),
		   		dataType:"json",
		       	success: function(json){ // data 保存提交后返回的数据，一般为 json 数据
		       		if(json.success){
		       			alert("添加成功");
		        		window.location.href="systemController.do?toCompanise";
		        		return false;
		       		}else{
		       			alert("添加失败，请重试");
		       		}
		       		return false;
		       	},
		       	error:function(){
		       		alert("您的网络可能出现问题，请重试！");
		       		return false;
		       	}
			})
		})
	})
	/**
     * 默认调用
     */
    !function () {
        var $target = $('#comRegionName');

        $target.citySelect();

        $target.on('click', function (event) {
            event.stopPropagation();
            $target.citySelect('open');
        });

        $target.on('done.ydui.cityselect', function (ret) {
            $(this).val(ret.provance + ' ' + ret.city + ' ' + ret.area);
        });
    }();
</script>
</html>